package com.h.mybatis.plus.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.h.mybatis.plus.model.Userinfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserInfoMapper extends BaseMapper<Userinfo> {
    // 对于 MyBatis-Plus 给的感觉不满足业务，那么可以进行自定义 SQL 语句

    // 自定义：select * from user_info where age=20 and username like "%min%"
    @Select("select * from user_info ${ew.customSqlSegment}")
    List<Userinfo> selectUserInfoByCondition(@Param(Constants.WRAPPER) Wrapper<Userinfo> wrapper);

    // 自定义：select * from user_info where age=25 and username like "%min%"
    List<Userinfo> selectUserInfoByCondition2(@Param(Constants.WRAPPER) Wrapper<Userinfo> wrapper);

    Integer updateUserInfoByCondition(Integer add,@Param(Constants.WRAPPER) Wrapper<Userinfo> wrapper);
}
